package ${package.Entity};

import com.baomidou.mybatisplus.annotation.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import lombok.experimental.Accessors;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ToString
@Accessors(chain = true)
@Schema(description = "${table.comment}")
public class ${entity} implements Serializable {

    private static final long serialVersionUID = 1L;

<#list table.fields as field>
    <#if field.keyFlag>
        <#assign keyPropertyName="${field.propertyName}"/>
    </#if>

    <#if field.keyFlag>
    /**
     * 主键 : ${field.name},  ${field.comment!}
     */
    @TableId(value = "${field.name}", type = IdType.AUTO)
    @Schema(description = "${field.comment!}")
    private ${field.propertyType} ${field.propertyName};
    <#-- 普通字段 -->
    <#elseif !field.keyFlag>
    /**
     * ${field.name},  ${field.comment!}
     */
    <#-- 乐观锁注解 -->
    <#if (versionFieldName!"") == field.name>
    @Version
    </#if>
    <#-- 逻辑删除注解 -->
    <#if (logicDeleteFieldName!"") == field.name>
    @TableLogic
    </#if>
    <#-- 添加Schema注解和其他条件注解 -->
    @Schema(description = "${field.comment!}")
    <#if field.propertyType == "String">
    @NotBlank(message = "${field.comment}不能为空")
    private String ${field.propertyName};
    <#elseif field.propertyType == "LocalDateTime">
    @NotNull(message = "${field.comment}不能为空")
    private LocalDateTime ${field.propertyName};
    <#else>
    @NotNull(message = "${field.comment}不能为空")
    private ${field.propertyType} ${field.propertyName};
    </#if>
    </#if>
</#list>
}